/**
 * 
 */
package com.lehecai.core.lottery.fetcher.jcgyj.impl;

import com.lehecai.core.exception.FetchFailedException;
import com.lehecai.core.lottery.LotteryType;
import com.lehecai.core.lottery.fetcher.FetcherType;
import com.lehecai.core.lottery.fetcher.jcgyj.AbstractJcgyjStaticInstantSpFetchWorker;
import com.lehecai.core.lottery.fetcher.jcgyj.JcgyjStaticInstantSpItem;
import com.lehecai.core.lottery.fetcher.jcgyj.impl.worker.CommonJcgyjStaticInstantSpFetchWorkerOfficial;
import com.lehecai.core.lottery.fetcher.jcgyj.impl.worker.CommonJcgyjStaticInstantSpFetchWorkerPengineAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * 通用竞彩足球sp抓取
 *
 */
public class CommonJcgyjStaticInstantSpFetcher extends BaseJcgyjStaticInstantSpFetcher {
	
	protected final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

	/**
	 * 获取默认抓取类型
	 * @return
	 */
	protected FetcherType getDefaultFetcherType(){
		return FetcherType.T_PENGINEAPI;
	}
	
	/**
	 * 从engineAPI抓取竞彩足球sp
	 * @param phase
	 * @return
	 */
	protected List<JcgyjStaticInstantSpItem> fetchPengineAPI(String phase, LotteryType lotteryType){
		AbstractJcgyjStaticInstantSpFetchWorker worker = new CommonJcgyjStaticInstantSpFetchWorkerPengineAPI();
        try {
            return worker.fetch(phase, lotteryType);
        } catch (FetchFailedException e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    protected List<JcgyjStaticInstantSpItem> fetchOfficial(String phase, LotteryType lotteryType){
        AbstractJcgyjStaticInstantSpFetchWorker worker = new CommonJcgyjStaticInstantSpFetchWorkerOfficial();
        try {
            return worker.fetch(phase, lotteryType);
        } catch (FetchFailedException e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }
}
